//
//  LGSingleReportDetailController.m
//  HeartDisease_YHJK
//
//  Created by 1234 on 2025/9/25.
//

#import "LGSingleReportDetailController.h"

//报告详情
#import "LGInspectDetailDoctorController.h"
//HIS报告详情
#import "LGReportDetailHisController.h"
#import "LGReportDetailItemCell.h"

@interface LGSingleReportDetailController ()
/**   */
@property (nonatomic , strong)LGReportDetailItemCell *topView;

@end

@implementation LGSingleReportDetailController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.title = @"报告详情";
    [self.view addSubview:self.topView];
    [self requestData];
}

-(void)requestData{
    [RequestUtil withPOST:@"/doctor/Visitrecords/reportDetailOne" parameters:@{@"record_id":self.recordid} withSign:YES success:^(NSInteger code, NSString *message, id returnData) {
        if(code == 200){
            NSDictionary *tempDic = returnData;
            self.topView.dataDic = returnData;
            //心康管家新改的
            NSArray *detail = tempDic[@"report_detail"];
            if (detail.count>0) {
                LGReportDetailHisController *controller = [[LGReportDetailHisController alloc]init];
                controller.view.frame = CGRectMake(0, kMaxY(self.topView.frame), Screen_W, Screen_H-kMaxY(self.topView.frame)-topBarHeight);
                controller.dataDic = tempDic;
                [self addChildViewController:controller];
                [self.view addSubview:controller.view];
            }else{
                //纯图片
                LGInspectDetailDoctorController *photoVC = [[LGInspectDetailDoctorController alloc]init];
                photoVC.view.frame = CGRectMake(0, kMaxY(self.topView.frame), Screen_W, Screen_H-kMaxY(self.topView.frame)-topBarHeight);
                photoVC.patientNum = tempDic[@"registration_no"];
                photoVC.patientid = tempDic[@"patient_id"];
                photoVC.photoArray = tempDic[@"files"];
    //            photoVC.anomalyArray = tempDic[@"items"];
                [self addChildViewController:photoVC];
                [self.view addSubview:photoVC.view];
            }
        }
    } error:^(NSError *error) {
        
    }];
}



#pragma mark
#pragma mark ====> 创建控件
-(LGReportDetailItemCell *)topView{
    if(!_topView){
        _topView = [[LGReportDetailItemCell alloc]initWithFrame:CGRectMake((Screen_W-viewPix(353))/2.0, viewPix(5), viewPix(353), viewPix(86))];
    }
    return _topView;
}

@end
